﻿using UnityEngine;
using System.Collections;

public class WeakSingletonBehaviour<T>
#if WRB_HIGHSTAKES
     : PopupMessageScreen where T : MonoBehaviour
#else
    : MonoBehaviour where T : MonoBehaviour
#endif
{
    static T _sharedInstance;

    protected static T sharedInstance {   get  { return _sharedInstance;   }  }
    public virtual void Awake()
    {
        if (!_sharedInstance)
            _sharedInstance = GetComponent<T>();
        else
            DestroyImmediate(this);
    }
    
    public virtual void OnDestroy()
    {
        _sharedInstance = null;
    }

}
